sugarfreeServices.factory('PageService',['ngTableParams',function(ngTableParams){
	var service = {};
	service.getTableParams=function(options){
		/**
		 * options{  
		 * 	limit,
		 *  expandParams,
		 *  getDataFn,
		 *  procResult
		 * }
		 */
		return new ngTableParams({
				page: 1,           
				count: options.expandParams.limit || 10           
			},{
				counts: [],
				total: 0, 
				getData:function($defer,params){
					params = angular.extend(params,options.expandParams);
					options.getDataFn(params).success(function (data){
							console.info('datadata',data);
							var result = options.procResult(data);
							params.total(result.total);
							$defer.resolve(result.list);
					});
				}
		});
	};
	
	return service;
}]);
